
enum IpAddrKind {
    V4,
    V6,
}
fn main() {
    println!("Hello, world!");

    let four = IpAddrKind::V4;

    let six = IpAddrKind::V6;


    route(four);

    route(six);


    let h = IpAddr::V4(127, 0, 0,1);

    let w = IpAddr::V6(String::from("::1"));


    let m = Message::Move { x: 6, y: 9 };
    let w = Message::Write(String::from("hello"));
    let q = Message::Quit;
    let c = Message::ChangeColor(125,33,88);

    m.call();

}


//将数据附加到枚举的变体中

enum IpAddr{
    V4(u8,u8,u8,u8),
    V6(String),
}


//为枚举定义方法

enum Message {
    Move{x:i32,y:i32},
    Write(String),
    Quit,
    ChangeColor(i32,i32,i32),
}

impl Message {
    fn call(&self) {
        
    }
}

fn route(ip:IpAddrKind) {
    
}